<?php

namespace app\admin\model;

use think\Model;


class OrderAppraise extends Model
{

    // 表名
    protected $name = 'order_appraise';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'receiving_text',
        'come_text',
        'service_text'
    ];

    public function getComeList()
    {
        return ['0' => __('Come 0'), '1' => __('Come 1'), '2' => __('Come 2'), '3' => __('Come 3'), '4' => __('Come 4'), '5' => __('Come 5')];
    }

    public function getComeTextAttr($value, $data)
    {
        $value = $value ? $value : $data['come'];
        $list = $this->getComeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getServiceList()
    {
        return ['0' => __('Service 0'), '1' => __('Service 1'), '2' => __('Service 2'), '3' => __('Service 3'), '4' => __('Service 4'), '5' => __('Service 5')];
    }

    public function getServiceTextAttr($value, $data)
    {
        $value = $value ? $value : $data['service'];
        $list = $this->getServiceList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getReceivingList()
    {
        return ['0' => __('Receiving 0'), '1' => __('Receiving 1'), '2' => __('Receiving 2'), '3' => __('Receiving 3'), '4' => __('Receiving 4'), '5' => __('Receiving 5')];
    }

    public function getReceivingTextAttr($value, $data)
    {
        $value = $value ? $value : $data['receiving'];
        $list = $this->getReceivingList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function recycler()
    {
        return $this->belongsTo('UserRecyclerInfo', 'recycler_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function order()
    {
        return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
